Understanding :link vs :visited Pseudo-Classes in CSS
In CSS, :link and :visited are pseudo-classes used to style anchor (<a>) elements depending on whether the link has been visited by the user.
:link – Targets all unvisited links. These are links the user has not clicked on yet.
:visited – Targets links that the user has already visited. Browsers restrict the styles that can be applied to protect user privacy.
Use :link and :visited to visually differentiate unvisited and visited links for better navigation experience.
In this example, links the user has not visited appear blue (:link), and links that have been visited appear purple (:visited). Hovering over any link changes its color and adds an underline.
Always use :link and :visited together to provide clear navigation cues.
Avoid using styles that violate privacy restrictions; only certain properties like color can be applied to :visited.
Combine with :hover and :active for consistent interactive feedback.
Test link styling across browsers as handling of visited links may vary.